<HTML><HEAD> <!-- ---------------------------------------- Hello World #9: Saying Hello using Links ---------------------------------------- --> <SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers /* THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com Copyright (c)1998 by Charles River Media. All Rights Reserved. This applet can only be re-used or modifed by license holders of the JavaScript Cookbook CD-ROM. Credit must be given in the source code and this copyright notice must be maintained. If you do not hold a license to the JavaScript Cookbook, you may NOT duplicate or modify this code for your own use. Use at your own risk. No warranty is given or implied of the suitability of this applet for any specific application. Neither Erica Sadun nor Charles River Media will be held responsible for any unwanted effects due to the use of this applet or any derivative. */ <!-- done hiding --></SCRIPT></HEAD> <BODY BGCOLOR="FFFFFF" LINK="000000" VLINK="000000" ALINK="007777"> <FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50 ALIGN = LEFT>Communications 109: Links</H1></FONT> <BLOCKQUOTE><FONT COLOR="770000"> The status bar greets the reader when the mouse is moved over the first link. The second link uses a JavaScript call in its address.<P> </FONT> <FONT SIZE=4> <A HREF="#" onMouseOver="window.status='Hello World';return true" onClick = "return true" >Move the Mouse over this Link</A><p> <A HREF="JavaScript:alert('Hello World')" >Click Me</A> </BLOCKQUOTE> <FONT COLOR="007777"><H2>Discussion</H2></FONT> This ninth "hello" recipe uses the links to greet the reader. The first link sets the <FONT COLOR="770000"> onMouseOver</FONT> event. When the mouse passes over the link, the status bar updates not to the document reference but rather to 'Hello World'.<p> The second uses a JavaScript HREF, not a document location. Rather than change addresses this JavaScript is executed. If the JavaScript returns any data, this becomes the new page. In this example, alert() does not, so the document content does not change. </FONT> <PRE><FONT COLOR="770000"> <A HREF="#" onMouseOver="window.status='Hello World';return true" onClick = "return true" >Move the Mouse over this Link</A> <A HREF="JavaScript:alert('Hello World')" >Click Me</A> </FONT></PRE> <h5>Copyright ©1996 by Charles River Media, All Rights Reserved</h5> </BODY> </HTML>